package com.gengzi.item.api;


import com.gengzi.common.pojo.PageResult;
import com.gengzi.item.bo.SpuBo;
import com.gengzi.item.pojo.Sku;
import com.gengzi.item.pojo.Spu;
import com.gengzi.item.pojo.SpuDetail;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * @author 董诗攀
 */
public interface GoodsApi {
    /**
     * 商品查询
     * @param key 条件
     * @param saleable 是否上架
     * @param page 当前页数
     * @param rows 每页行数
     * @return 分页结果
     */
    @GetMapping("/spu/page")
    PageResult<SpuBo> querySpuByPage(
            @RequestParam(value = "page", defaultValue = "1") Integer page,
            @RequestParam(value = "rows", defaultValue = "5") Integer rows,
            @RequestParam(value = "saleable", required = false) Boolean saleable,
            @RequestParam(value = "key", required = false) String key);

    /**
     * 根据spuId查询spuDetail
     * @param spuId 商品集id
     * @return 商品集详情
     */
    @GetMapping("spu/detail/{spuId}")
    SpuDetail querySpuDetailBySpuId(@PathVariable("spuId") Long spuId);

    /**
     *根据spuId查询sku的集合
     * @param spuId 商品集id
     * @return sku集合
     */
    @GetMapping("sku/list")
    List<Sku> querySkusBySpuId(@RequestParam("spuId") Long spuId);
    


    /**
     * 根据spu的id查询spu
     * @param id
     * @return
     */
    @GetMapping("spu/{id}")
    Spu querySpuById(@PathVariable("id") Long id);


}
